package user.dto;

import jakarta.validation.constraints.NotNull;
import lombok.*;

import java.io.Serializable;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserDto implements Serializable {
    private int userId;
    private String username;
    private String password;
    private String email;
    private Date createdAt;
    private int height;
    private int weight;
    private int age;
    private int sex;
    private float protein;
    private double energy;
    private float fats;
    private float carbohydrate;
    private int exerciseLevel;
    private int type;
    private int AICount;
    public void calculateNutrientNeeds() {
        // Calculate BMR
        double bmr;
        if (sex == 0) { // Male
            bmr = 88.36 + (13.4 * weight) + (4.8 * height) - (5.7 * age);
        } else { // Female
            bmr = 447.6 + (9.2 * weight) + (3.1 * height) - (4.3 * age);
        }

        // Determine activity factor based on exercise level
        double activityFactor;
        switch (exerciseLevel) {
            case 1: activityFactor = 1.2; break; // Sedentary
            case 2: activityFactor = 1.375; break; // Lightly active
            case 3: activityFactor = 1.55; break; // Moderately active
            case 4: activityFactor = 1.725; break; // Very active
            case 5: activityFactor = 1.9; break; // Super active
            default: activityFactor = 1.2; break; // Default to sedentary
        }

        // Calculate TDEE
        energy = bmr * activityFactor;

        // Calculate macro nutrient needs
        // Example ratio: Protein 25%, Fats 25%, Carbs 50%
        protein = (float) (energy * 0.25 / 4); // 4 calories per gram of protein
        fats = (float) (energy * 0.25 / 9); // 9 calories per gram of fat
        carbohydrate = (float) (energy * 0.50 / 4); // 4 calories per gram of carbohydrate
    }

}